package com.zhoukun.cloud.controller;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.zhoukun.cloud.service.userService;
import com.zhoukun.cloud.CommentRest;
import com.zhoukun.cloud.user;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;

/**
 * @author zhoukun 86547462@qq.com
 * @version 1.0
 * @date 2020/10/24 19:44
 */
@RestController
@Slf4j
public class PaymentController {
    @Autowired
    userService service;


    //查询
    @GetMapping("/payment/query")
    public CommentRest query()
    {
        return new CommentRest()
                .setCode(200)
                .setMessage("success")
                .setData(service.list());
    }


    //查询单个
    @GetMapping("/payment/queryById/{Id}")
    public CommentRest queryById(@PathVariable String Id)
    {
        return new CommentRest()
                .setCode(200)
                .setMessage("success")
                .setData(service.getById(Id));
    }

    //修改余额
    @GetMapping("/payment/banUP/{Id}/{money}")
    public CommentRest banUP(@PathVariable String Id,
                                @PathVariable BigDecimal money)
    {

        UpdateWrapper<user> wrapper=new UpdateWrapper<user>();
        wrapper.eq("id",Id);
        return new CommentRest()
                .setCode(200)
                .setMessage("success")
                .setData(service.update(new user().setBalance(money),wrapper));
    }





}
